#define _CRT SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Gloves {
public:
    int findMinimum(int n, vector<int> left, vector<int> right) {
        // write code here
        int arr[14] = { 0 };
        int color = 0;
        int flag = 0;
        for (int i = 0; i < n; i++)
        {
            if (left[i] == 0 || right[i] == 0)
            {
                arr[color++] = i;
                flag = 1;
            }
        }
        int sum1 = 0, sum2 = 0;
        for (int i = 0; i < color; i++)
        {
            sum1 += left[arr[i]];
            sum2 += right[arr[i]];
        }
        sum1 += 1;
        sum2 += 1;
        int j = 0;
        int s1 = 0, s2 = 0;
        int min1 = 10000, min2 = 10000;
        for (int i = 0; i < n; i++)
        {
            if (i == arr[j]&&flag==1)
            {
                j++;
                continue;
            }
            if (min1 > left[i])
            {
                min1 = left[i];
            }
            if (min2 > right[i])
            {
                min2 = right[i];
            }
            s1 += left[i];
            s2 += right[i];
        }
        s1 = s1 - min1 + sum1;
        s2 = s2 - min2 + sum2;
        sum1 += s2;
        sum2 += s1;
        int min = (sum1 > sum2) ? sum2 : sum1;
        return min;
    }
};
int main()
{
    vector<int> a(10);
    vector<int> b(10);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    Gloves c;
    int ret = c.findMinimum(n, a, b);
    cout << ret;
    return 0;
}
